﻿<?php
require('pub.php'); 
require(_ROOT.'/db.php');
require(_ROOT.'/title.php');
?>
<?php
	$var_year  = $_REQUEST['year'];
	$var_level = $_REQUEST['level'];
	$var_class = $_REQUEST['class'];
	
	if ($var_year!="" || $var_level!="" || $var_class!="")	
	{
		//从var_year中提取出year和month后整合成新的mark标志
		$var_y = substr($var_year,0,4);
		$var_m = substr($var_year,5,2);
		$var_mark = $var_y.$var_m.$var_level.$var_class;
?>
<div id="floatshowdiv" style="border:solid 1px #ddd;display:none;height:22px;line-height:22px;zindex:99;background:#EFEFEF;"></div>
<table width="768" align="center">
	<tr><td><div class="h12b">试卷Mark标志: <?php echo $var_mark;?></div></td></tr>
</table>

<table width="768" align="center">
		<?php
		$sql = 	' select t_title.t_mark,t_text.t_eid,t_tid,t_title,t_ques,opta,optb,optc,optd,t_key,t_keyEx,t_point,t_eid_start,t_eid_end'.
				' from t_text,t_title'.
				' where t_text.t_mark = t_title.t_mark and t_title.t_mark = '.$var_mark.' and t_eid >=t_eid_start and t_eid <=t_eid_end'.
				' order by t_tid,t_text.t_eid';
				
		$data = mysql_query($sql, $conn);
		
		$counter=0;		//已显示的次数
		$temp=0;		//剩余显示text的次数
		$num=0;			//需要显示的text次数
		$flag=1;		//标题是否需要显示
		$count = 0;		//当前题库题目数
	
		while ($arr = mysql_fetch_array($data))
		{
			$num=$arr['t_eid_end']-$arr['t_eid_start']+1;	//获取需要显示的记录数
			if ($flag==1)	//显示第一条记录标题和正文
			{
				?>
				<tr><td bgcolor="#CCCCCC">
					<div class="h9u">第<?php echo $arr[t_tid]; ?>个标题 T_Mark: <?php echo $arr[t_mark],$arr[t_tid]; ?></div>
					<?php echo $arr[t_title]; ?><br /></td></tr>
				<tr><td height="1" bgcolor="EFEFEF"></td></tr>
				<?php
				$flag	 = 0;			//标题只显示一次
				$temp	 = $num;
				$num	 = $num-1;
				$counter = $counter+1;
				$count	 = $count+1;
				//echo '<br />1 flag='.$flag.' temp='.$femp.' num='.$num.' counter='.$counter.'<br />';
			}
			elseif ($counter<$temp) 
			{
				$num	 = $num-1;
				$counter = $counter+1;
				$count	 = $count+1;
				//echo '<br />2 num='.$num.' counter='.$counter.'<br />';
			}
			else
			{
				//显示标题和正文
				$flag	 = 1;	//所有标志置空
				$temp	 = 0;
				$counter = 0;
				$num	 = 0;
				//echo '<br />3 flag='.$flag.' temp='.$femp.' num='.$num.' counter='.$counter.'<br />';
				$num=$arr['t_eid_end']-$arr['t_eid_start']+1;	//获取需要显示的记录数
				?>
				<tr><td bgcolor="#CCCCCC">
					<div class="h9u">
						第<?php echo $arr[t_tid]; ?>个标题 T_Mark: <?php echo $arr[t_mark],$arr[t_tid]; ?></div>
						<?php echo $arr[t_title]; ?>
				</td></tr>
				<tr><td height="1" bgcolor="EFEFEF"></td></tr>
				<?php
				$flag	 = 0;			//标题只显示一次
				$temp	 = $num;
				$num	 = $num-1;
				$counter = $counter+1;
				$count	 = $count+1;
			}
			?>
			<tr id="<?php echo $count;?>" onmouseover="tr_mouseover(event,this)" onmouseout="tr_mouseout(event,this)" onmousemove="tr_mousemove(event,this)">
				<td width="600">
					<div class="h9u">EID:<?php echo $arr[t_eid]; ?> E_Mark: <?php echo $arr[t_mark],$arr[t_tid],$arr[t_eid]; ?> 分值: <b><?php echo $arr[t_point]; ?></b></div>
					题目: <?php
							$var_len = strlen($arr[t_ques]);
							echo 'Len('.$var_len.') ';
							if ($var_len!=0)
								{
									echo $arr[t_ques];
									?>
									<font color="#F4F4F4"><script> var str = randomStr(10); document.write (str);</script></font><br />
									<?php
								}
							else
								{
									?>
									本题题目为空，请参考标题内容！<font color="#F4F4F4"><script> var str = randomStr(10); document.write (str);</script></font><br />
									<?php
								}
							?>
					
					A: <?php echo $arr[opta]; ?> <br />
					B: <?php echo $arr[optb]; ?> <br />
					C: <?php echo $arr[optc]; ?> <br />
					D: <?php echo $arr[optd]; ?> <br />
				</td>
			</tr>
			<script language="JavaScript">
			var id = <?php
					// 将<tr></tr>的id及值送入KeyArr数组 
					echo $count;
					?>;
			keyArray("<?php echo $count;?>", "<?php echo $arr[t_key];?>", "<?php echo $arr[t_keyEx];?>");
			</script>
			<tr><td height="1" bgcolor=""></td></tr>
			<?php
		}
		mysql_free_result($data);
		?>
</table>
<table width="768" align="center">
	<tr>
		<td>
			<br />当前题目总数: 
			<?php echo $count; ?>条
		</td>
	</tr>
</table>
<table width="768" align="center">
<tr>
<td>
<script language="javascript">
	//free_KeyArray( keyArr );
</script>
</td>
</tr>
</table>
	<?php
	}
	else
	{
		echo '<table width=768 align=center><tr><td><div class=h12 >传递内容为空，或非法！';
		echo '<br />'.$var_year.' '.$var_level.' '.$var_class.'</div></td></tr></table>';
	}
require(_ROOT.'/bottom.php');
?>